package routers

import (
	"gin-web-demo/controllers"

	"github.com/gin-gonic/gin"
)

func SetupRouter() *gin.Engine {
	r := gin.Default()

	userController := new(controllers.UserController)

	// 用户路由
	userGroup := r.Group("/users")
	{
		userGroup.GET("", userController.GetUsers)
		userGroup.GET("/:id", userController.GetUser)
		userGroup.POST("", userController.CreateUser)
		userGroup.PUT("/:id", userController.UpdateUser)
		userGroup.DELETE("/:id", userController.DeleteUser)
	}

	fsoController := new(controllers.FsoController)
	// 汛情数据
	fsoGroup := r.Group("/fsos")
	{
		fsoGroup.GET("", fsoController.GetFsos)
		fsoGroup.GET("/:id", fsoController.GetFso)
		fsoGroup.POST("", fsoController.CreateFso)
		fsoGroup.PUT("/:id", fsoController.UpdateFso)
		fsoGroup.DELETE("/:id", fsoController.DeleteFso)
	}

	// 健康检查
	r.GET("/health", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"status": "ok",
		})
	})

	return r
}
